<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>AJAX calls using Jquery in Servlet</title>

        <!-- <script src="http://code.jquery.com/jquery-latest.min.js"></script>  -->
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
       
        <script>
            $(document).ready(function() {                        
                $('#submit').click(function(event) {
             
                	var request = $.ajax({
                		dataType: "json",
                    	type: "GET",
                    	url: "/Ajax/AjaxJsonServlet",          
          			  	cache: false
          			});
                    
                    request.done(function( json ) {
                    	window.console && console.log(json);
          			});
                    
                    request.fail(function(jqXHR, textStatus) {
                    	  alert( "Request failed: " + textStatus );
                    });
                    
                });
            });
        </script>
</head>
<body>
<form id="form1">
<h1>JSON Demo</h1>
<br/><br/>
<input type="button" id="submit" value="Ajax Submit"/>
</form>
</body>
</html>